package portal.mybatis.dao.service;

import java.util.Date;
import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import beans.HistoryTask;
import beans.Task;
import portal.mybatis.dao.mapper.HistoryTaskMapper;

@Service
public class HistoryTaskService {
	@Autowired
	HistoryTaskMapper htMapper;
/*	public boolean addHistoryByTask(Task task, String taskHash, String orders, String batchTaskHash){
		HistoryTask ht=new HistoryTask(task,taskHash,orders,batchTaskHash,"running");
		htMapper.addHistoryByTask(ht);
		List<HistoryTask> th=htMapper.getHistoryTaskByTaskHash(taskHash);
		if(th==null ||th.size()==0)
			return false;
		return true;
	}
	public boolean addBatchTask(Task task, String taskHash, String orders,Date date){
		HistoryTask ht=new HistoryTask(task,taskHash,orders,null,"running");
		htMapper.addBatchTask(ht);
		List<HistoryTask> th=htMapper.getHistoryTaskByTaskHash(taskHash);
		if(th==null ||th.size()==0)
			return false;
		return true;
	}*/
	public HistoryTask getHistoryTaskByTaskHash(String taskHash){
		List<HistoryTask>list= htMapper.getHistoryTaskByTaskHash(taskHash);
		if(list==null || list.size()==0)
			return null;
		return list.get(0);
	}
}
